//index.js
//获取应用实例
const app = getApp()
 const Api = require("../../utils/api.js").API
// const Store = require("../../utils/store.js").store
// const codeZ = require("../../utils/util.js")
Page({
    data: {
       list:[],
        hei2:300,
        page:1,
      
    },
    onLoad() {
       
    },
    onShow: function() {
        let that = this;
        this.setData({
            
             hei2:(app.globalData.screenHeight-100),
            });
             this.getShopList(1);
     
     
    },
    
    refreshBottom: function() {
        var that = this
        var a = this.data.page;
        
        var listArr = this.data.list.length;
      
       
        if (listArr == this.data.total) {
            
            // this.setData({
            //     isShow: true
            // })
            return;
        }else{
            
            a++;
            that.setData({
                page: a
            })
            
            
            this.getShopList(a);
            
        }
       
    
    },
    getShopList(page){
        let that =this;
        let a = {"page":page,"limit":10}
         
        Api.cpListApi(a).then(res=>{
            if(res.code == 0){
                var arr = res.page.records;
                arr.forEach(item=>{
                    item.evFile = JSON.parse(item.evFile);
                })
                var oldArr = that.data.list;
                   
                var newArr = oldArr.concat(arr);
                that.setData({
                    list:newArr
                })
            }
        })
        
    },
    
        
    clickJump:function(e){
        let i = e.currentTarget.dataset.item['evNo'];   
         if(i == null){
             return
         }
        wx.navigateTo({
                url: '../DetailData/index',
                   success: function(res) {
                     // 通过eventChannel向被打开页面传送数据
                     res.eventChannel.emit('acceptDataFromOpenerPage', { data:i })
                   }
           })    
    },
  
});
